home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / Conference / Source / ConferenceListener.m < prev    next >
Text File  |  1993-01-19  |  2KB  |  94 lines

  1. #import <appkit/appkit.h>
  2. #import "ConferenceListener.h"
  3. #import <mach.h>
  4. #import <sys/message.h>
  5. #import <servers/netname.h>
  6. extern port_t name_server_port;
  7. extern id NXResponsibleDelegate();
  8. @implementation  ConferenceListener :Listener
  9. {}
  10. static NXRemoteMethod *remoteMethods = NULL;
  11. #define REMOTEMETHODS 3
  12. + (void)initialize 
  13. /* */
  14. {
  15.     if (!remoteMethods) {
  16.     remoteMethods =
  17.     (NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
  18.     remoteMethods[0].key = 
  19.     @selector(helloIAm:length:);
  20.     remoteMethods[0].types = "b";
  21.     remoteMethods[1].key = 
  22.     @selector(goodByeIAmLeaving:length:);
  23.     remoteMethods[1].types = "b";
  24.     remoteMethods[2].key = 
  25.     @selector(sendMessage:from:length:);
  26.     remoteMethods[2].types = "cb";
  27.     remoteMethods[REMOTEMETHODS].key = NULL;
  28.     }
  29. }
  30. -(int)helloIAm : (char *) fr
  31.     length : (int) len
  32. /* */
  33. {
  34.     id _NXd;
  35.     if (_NXd = NXResponsibleDelegate(self,
  36.     @selector(helloIAm:length:)))
  37.     return [_NXd helloIAm : fr
  38.         length : len];
  39.     return -1;
  40. }
  41.  
  42. -(int)goodByeIAmLeaving : (char *) fr
  43.     length : (int) len
  44. /* */
  45. {
  46.     id _NXd;
  47.     if (_NXd = NXResponsibleDelegate(self,
  48.     @selector(goodByeIAmLeaving:length:)))
  49.     return [_NXd goodByeIAmLeaving : fr
  50.         length : len];
  51.     return -1;
  52. }
  53.  
  54. -(int)sendMessage : (char *) msg
  55.     from : (char *) fr
  56.     length : (int) len
  57. /* */
  58. {
  59.     id _NXd;
  60.     if (_NXd = NXResponsibleDelegate(self,
  61.     @selector(sendMessage:from:length:)))
  62.     return [_NXd sendMessage : msg
  63.         from : fr
  64.         length : len];
  65.     return -1;
  66. }
  67.  
  68. - (int) performRemoteMethod : (NXRemoteMethod *) method
  69.                   paramList : (NXParamValue *) paramList {
  70. /* */
  71.     switch (method - remoteMethods) {
  72.     case 0:
  73.     return [self helloIAm : paramList[0].bval.p
  74.         length : paramList[0].bval.len];
  75.     case 1:
  76.     return [self goodByeIAmLeaving : paramList[0].bval.p
  77.         length : paramList[0].bval.len];
  78.     case 2:
  79.     return [self sendMessage : paramList[0].bval.p
  80.         from : paramList[1].bval.p
  81.         length : paramList[1].bval.len];
  82.     default:
  83.     return [super performRemoteMethod : method paramList : paramList];
  84.     }
  85. }
  86. - (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
  87. /* */
  88.     NXRemoteMethod *rm;
  89.     if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
  90.         return rm;
  91.     return [super remoteMethodFor : aSel];
  92. }
  93. @end
  94.